rm(list = ls())
library(readstata13)
library(plyr)
library(plotrix)
library(foreign)
library(stargazer)
library(ggplot2)
library(stm)
library(dplyr)
library(zoo)
library(car)
library(plyr)
library(knitr)
library(qwraps2)
library(knitr)
library(xtable)
library(qwraps2)
library(tibble)
library(gdata)
library(tidyr)
library(data.table)
library(stringr)
library(reshape2)
library(ggrepel)
library(dfadjust)
library(lmtest)
library(summarytools)
library(kableExtra)
library(experiment)
library(AER)
library(sandwich)
#library(ivpack)
library(psych)
library(remotes)
library(stats)
library(GMCM)

setwd("~/Dropbox/Participacion Politica FARC/Data_workshops/Replication/Dataverse files")

load("data_notimputed.RData")
load("data_imputed.RData")

imputedT <- subset(imputed, treatment=="1")
imputedT <- as_tibble(imputedT)
imputedT <- merge(imputedT, imputedT %>% dplyr::count(schooling), by = "schooling")
colnames(imputedT)[length(colnames(imputedT))] <- "N"

imputedC <- subset(imputed, treatment=="0")
imputedC <- as_tibble(imputedC)
imputedC <- merge(imputedC, imputedC %>% dplyr::count(schooling), by = "schooling")
colnames(imputedC)[length(colnames(imputedC))] <- "N"


#### Figure 2: Site locations ####
table(imputed$municipio)

#### Table 1: Summary statistics and balance (N = 275, 158 treated, 117 control) ####
summary <- round(as.data.frame(colMeans(imputedC[c(1,4:5,24:40,43,44)])), 2)
colnames(summary)[1] <- "controlmeans"
summary$treatedmeans <- round(sapply(imputedT[c(1,4:5,24:40,43,44)], mean,na.rm = T),2)
summary$controlsd<- round(sapply(imputedC[c(1,4:5,24:40,43,44)], sd,na.rm = T),2)
summary$treatedsd<- round(sapply(imputedT[c(1,4:5,24:40,43,44)], sd,na.rm = T),2)
summary$coef <- NA

imputed$treated <- as.factor(imputed$treatment)

myvars <- as.list(rownames(summary))
balance <- lapply(myvars, function(dvar)
  lm(as.formula(paste0(dvar, " ~treated")),data=imputed))

for(i in 1:22){
  summary$coef[i] <- round(balance[[i]]$coefficients[2],2)
}

#Population means which were obtained from UN-CNR (2017) report of the census of demobilized FARC ex-combanats
summary$population <- ifelse(rownames(summary) == "entre18y40", 0.72,NA)
summary$population <- ifelse(rownames(summary) == "noneorbasic", 0.68,summary$population)
summary$population <- ifelse(rownames(summary) == "sexo", 0.33,summary$population)
summary$population <- ifelse(rownames(summary) == "negro", 0.12,summary$population)
summary$population <- ifelse(rownames(summary) == "indigena", 0.18,summary$population)

summary$min <- round(sapply(dplyr::select(imputed,schooling, gender, age, trust_score, participation_score, democracy_score, moderation_platform,
                                   moderation_alliance, moderation_score, sat_implementationfarc, ideology_personal, farc_loyalrevolutionary,
                                   voted2016, lifethreat, shot, combat, conflict_score, blanco, negro, indigena,
                                   noneorbasic, between18y40), min,na.rm = T),2)

summary$max <- round(sapply(dplyr::select(imputed,schooling, gender, age, trust_score, participation_score, democracy_score, moderation_platform,
                                          moderation_alliance, moderation_score, sat_implementationfarc, ideology_personal, farc_loyalrevolutionary,
                                          voted2016, lifethreat, shot, combat, conflict_score, blanco, negro, indigena,
                                          noneorbasic, between18y40), max,na.rm = T),2)

summary <- summary[, c( 7, 8, 3, 4, 5, 1,2,6)]

sink(file = "table-1.tex")
stargazer(summary, summary = F, digits = 2, type = "latex", title = "Summary statistics and balance (N = 275, 158 treated, 117 control)")
sink()
#### Table 2: Effects on Trust and Participation (ITT) ####
#without controls
tscore <- coeftest(lm(trust_score ~  assignment + factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
dscore <- coeftest(lm(democracy_score ~ assignment + factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
pscore <- coeftest(lm(participation_score~  assignment + factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

#with controls
tscorei <- coeftest(lm(trust_score ~  assignment+ gender + age  + negro + indigena + blanco + schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0") 
dscorei <- coeftest(lm(democracy_score ~ assignment+ gender + age + negro + indigena + blanco+  schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0") 
pscorei <- coeftest(lm(participation_score ~  assignment+ gender + age + negro + indigena + blanco+ schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-2.tex")
stargazer(tscore, tscorei, dscore,  dscorei, pscore, pscorei,
          title = "Effects on Trust and Participation (ITT)", align = T, digits = 2, keep = "assignment",
          type = "latex", header = FALSE, omit = c("municipio", "gender", "age", "negro", "indigena", "blanco", "schooling", "conflict_score"))
sink()
#### Table 3: Support for Party Moderation (ITT) ####
#without controls
mscore <- coeftest(lm(moderation_score ~  assignment + factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
mbeh <- coeftest(lm(moderation_alliance ~ assignment + factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
mide <- coeftest(lm(moderation_platform~  assignment + factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

#with controls
mscorei <- coeftest(lm(moderation_score ~  assignment+ gender + age  + negro + indigena + blanco + schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
mbehi <- coeftest(lm(moderation_alliance ~ assignment+ gender + age + negro + indigena + blanco+  schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
midei <- coeftest(lm(moderation_platform ~  assignment+ gender + age + negro + indigena + blanco+ schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-3.tex")
stargazer(mscore, mscorei, mbeh, mbehi,  mide, midei,
          title = "Support for Party Moderation (ITT)", align = T, digits = 2,keep = "assignment",
          type = "latex", header = FALSE, omit = "municipio")
sink()
#P-value adjustment for multiple comparisons
p1 <- round(p.adjust(c(mscore[2,4], mscorei[2,4],mbeh[2,4],mbehi[2,4],mide[2,4],midei[2,4]), "BH"),3)
p1

#### Table A 1: Summary Statistics Raw Data ####
sink(file = "table-A1.tex")
stargazer(farc, digits = 2, keep = c("assignment", "age", "entre18y40", "schooling", "noneorbasic","gender", "blanco", "negro", "indigena", "conflict_score", 
                                     "moderation_alliance", "moderation_platform","moderation_score", "trust_score", "democracy_score", "participation_score",
                                     "ideology_personal","FARCFIELAIDEASREVOL","IMPLEMFARC","ELECCIONES2016"), omit.summary.stat = c("p25", "p75"), title = "Summary Statistics Raw Data")
sink()

#### Table A 2: Summary statistics of ex-combatants’ FARC-EP experience (no imputation) ####
sink(file = "table-A2.tex")
stargazer(farc, digits = 2, keep = c("pdr", "front_size", "entry_age", "unit_pride", "commander_interest", "debate", "ideological_education",
                                     "electoral_education","combat", "lifethreat", "shot", "civil_reject", "sat_accord", "sat_implementation"),  omit.summary.stat = c("p25", "p75"), title = "Summary statistics of ex-combatants' FARC-EP experience (no imputation)")
sink()
#### Table A 3: Heterogeneous effects by ex-combatant report of currently undergoing reinsertion process ####
hp3 <- coeftest(lm(moderation_score ~ assignment*pdr + gender + age + schooling  + negro + indigena + blanco + conflict_score+ factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
hp4 <- coeftest(lm(trust_score ~ assignment*pdr + gender + age + schooling  + negro + indigena + blanco + conflict_score+ factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
hp5 <- coeftest(lm(democracy_score ~ assignment*pdr + gender + age + schooling  + negro + indigena + blanco +conflict_score+factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
hp6 <-  coeftest(lm(participation_score ~ assignment*pdr + gender + age + schooling  + negro + indigena + blanco + conflict_score+factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-A3.tex")
stargazer(hp3,hp4,hp5,hp6,
          title = "Heterogeneous effects by ex-combatant report of currently undergoing reinsertion process", align = T, digits = 2, keep = c("assignment", "pdr"),
          type = "latex", header = FALSE, omit = "municipio")
sink()
#### Table A 4 and 5: Effects on Trust in Institutions (ITT) ####
#without imputed data
tgob <- coeftest(lm(trust_gov ~  assignment+ gender + age  + negro + blanco +indigena + schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")
talc <- coeftest(lm(trust_mayors ~  assignment+ gender + age  + negro +  blanco +indigena + schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")
tcon <- coeftest(lm(trust_council ~  assignment+ gender + age  + negro +  blanco +indigena + schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")
tele <- coeftest(lm(trust_elec2019 ~  assignment+ gender + age  + negro +  blanco +indigena + schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")
tjus <- coeftest(lm(trust_justice ~  assignment+ gender + age  + negro +  blanco +indigena + schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")
tjep <- coeftest(lm(trust_jep ~  assignment+ gender + age  + negro +  blanco +indigena + schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")

#with imputed data
tgobi <- coeftest(lm(trust_gov ~  assignment+ gender + age  + negro + blanco + indigena + schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
talci <- coeftest(lm(trust_mayors ~  assignment+ gender + age  + negro +  blanco +indigena + schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
tconi <- coeftest(lm(trust_council ~  assignment+ gender + age  + negro + blanco + indigena + schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
telei <- coeftest(lm(trust_elec2019 ~  assignment+ gender + age  + negro + blanco + indigena + schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
tjusi <- coeftest(lm(trust_justice ~  assignment+ gender + age  + negro + blanco + indigena + schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
tjepi <- coeftest(lm(trust_jep ~  assignment+ gender + age  + negro + blanco + indigena + schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-A4.tex")
stargazer(tcon, tconi, tgob, tgobi, tjus, tjusi,
          title = "Effects on Trust in Institutions (ITT)", align = T, digits = 2, keep = "assignment", 
          type = "latex", header = FALSE, omit = "municipio")
sink()
sink(file = "table-A5.tex")
stargazer(talc, talci, tjep, tjepi, tele ,telei, 
          title = "Effects on Trust in Institutions (ITT) (continued)", align = T, digits = 2, keep = "assignment", 
          type = "latex", header = FALSE, omit = "municipio")
sink()
#### Table A 6 and 7: Effects on Trust in Democracy (ITT) ####
#without imputed data
dinc<- coeftest(lm(system_inclusive ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")
dmej <- coeftest(lm(democracy_best ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")
dmet <- coeftest(lm(farc_goals ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")
dvoz <- coeftest(lm(voice_ingov ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")
deff <- coeftest(lm(mecdem_efficient ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")

#with imputed data
dinci <- coeftest(lm(system_inclusive ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
dmeji <- coeftest(lm(democracy_best ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
dmeti <- coeftest(lm(farc_goals ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
dvozi <- coeftest(lm(voice_ingov ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
deffi <- coeftest(lm(mecdem_efficient ~  assignment+ gender + age  + negro + indigena +blanco+  schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-A6.tex")
stargazer(dinc, dinci, dmej, dmeji, dmet, dmeti,
          title = "Effects on Trust in Democracy (ITT)", align = T, digits = 2, keep = "assignment", 
          type = "latex", header = FALSE, omit = "municipio")
sink()
sink(file = "table-A7.tex")
stargazer(dvoz, dvozi, deff, deffi,
          title = "Effects on Trust  in Democracy (ITT) (continued)", align = T, digits = 2, keep = "assignment", 
          type = "latex", header = FALSE, omit = "municipio")
sink()
#### Table A 8: Effects on Participation in Democracy (ITT) ####
#without imputed data
pfarc <- coeftest(lm(support_farc_candidate ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")
pcam <- coeftest(lm(plan_campaigning ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")
pele <- coeftest(lm(plan_vote2019 ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")

#with imputed data
pfarci <- coeftest(lm(support_farc_candidate ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
pcami <- coeftest(lm(plan_campaigning ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
pelei <- coeftest(lm(plan_vote2019 ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(imputed$municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-A8.tex")
stargazer(pele, pelei, pfarc, pfarci, pcam, pcami, 
          title = "Effects on Participation in Democracy (ITT)", align = T, digits = 2, keep = "assignment", 
          type = "latex", header = FALSE, omit = "municipio")
sink()
#### Table A 9: Effects on moderation with no outcome imputation (ITT) ####
#without imputed data
mscorer <- coeftest(lm(moderation_score ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")
mbehr <- coeftest(lm(moderation_alliance ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")
mider <- coeftest(lm(moderation_platform ~  assignment+ gender + age  + negro + indigena + blanco+ schooling+ conflict_score+ factor(farc$municipio), data = farc, weight = farc$weight),vcov = vcovHC, type = "HC0")

sink(file = "table-A9.tex")
stargazer(mscorer, mbehr, mider,
          title = "Effects on moderation with no outcome imputation (ITT)", align = T, digits = 2, keep = "assignment", 
          type = "latex", header = FALSE, omit = "municipio")
sink()
#### Table A 10: Heterogeneous treatment effect by gender on moderation ####
imputed$cent_gender <- imputed$gender - mean(imputed$gender, na.rm = T)
g4 <- coeftest(lm(moderation_score ~ assignment*cent_gender   + negro + indigena + blanco + schooling + age + conflict_score+ factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
g5 <- coeftest(lm(moderation_alliance ~ assignment*cent_gender   + negro + indigena + blanco + schooling + age + conflict_score+ factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
g6 <-  coeftest(lm(moderation_platform ~ assignment*cent_gender  + negro + indigena + blanco + schooling + age + conflict_score+ factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-A10.tex")
stargazer(g4,g5,g6, omit = "municipio", keep = c("assignment","cent_gender"), 
          title = "Heterogeneous treatment effect by gender on moderation")
sink()
#P-values adjusted for multiple comparisons
round(p.adjust(c(g4[2,4], g5[2,4],g6[2,4]), "BH"),3)
round(p.adjust(c(g4[3,4], g5[3,4],g6[3,4]), "BH"),3)
round(p.adjust(c(g4[16,4], g5[16,4],g6[18,4]), "BH"),3)

#### Table A 11: Heterogeneous treatment effect by gender on trust and participation ####
g1 <- coeftest(lm(trust_score ~ assignment*cent_gender  + negro + indigena + blanco + schooling + age + conflict_score + factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
g2 <- coeftest(lm(democracy_score ~ assignment*cent_gender  + negro + indigena + blanco + schooling + age + conflict_score +  factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
g3 <-  coeftest(lm(participation_score ~ assignment*cent_gender  + negro + indigena + blanco + schooling + age + conflict_score +  factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-A11.tex")
stargazer(g1,g2,g3, omit = "municipio", keep = c("assignment","cent_gender"), 
          title = "Heterogeneous treatment effect by gender on trust and participation")
sink()
#### Table A 12: Heterogeneous treatment effect by age on trust and participation ####
imputed$cent_age <- imputed$age - mean(imputed$age, na.rm = T)
a1 <- coeftest(lm(trust_score ~ assignment*cent_age  + negro + indigena + blanco +schooling + gender + conflict_score +factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
a2 <- coeftest(lm(democracy_score ~ assignment*cent_age  + negro + indigena + blanco +schooling + gender + conflict_score +factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
a3 <-  coeftest(lm(participation_score ~ assignment*cent_age +blanco + negro + blanco +indigena + schooling + gender + conflict_score + factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-A12.tex")
stargazer(a1,a2,a3, omit = "municipio", keep = c("assignment","cent_age"), 
          title = "Heterogeneous treatment effect by age on trust and participation")
sink()
#### Table A 13: Heterogeneous treatment effect by age on moderation ####
a4 <- coeftest(lm(moderation_score ~ assignment*cent_age +blanco + negro + indigena + blanco+schooling + gender + conflict_score+ factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
a5 <- coeftest(lm(moderation_alliance ~ assignment*cent_age +blanco + negro + indigena + blanco+schooling + gender + conflict_score+ factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
a6 <-  coeftest(lm(moderation_platform ~ assignment*cent_age +blanco + negro + indigena + blanco+schooling + gender + conflict_score+ factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
sink(file = "table-A13.tex")
stargazer(a4,a5,a6, omit = "municipio", keep = c("assignment","cent_age"), 
          title = "Heterogeneous treatment effect by age on moderation")
sink()
#P-values adjusted for multiple comparisons
round(p.adjust(c(a4[2,4], a5[2,4],a6[2,4]), "BH"),3)
round(p.adjust(c(a4[3,4], a5[3,4],a6[3,4]), "BH"),3)
round(p.adjust(c(a4[16,4], a5[16,4],a6[18,4]), "BH"),3)

#### Table A 14: Heterogeneous treatment effect by education on moderation ####
imputed$cent_schooling <- imputed$schooling  - mean(imputed$schooling , na.rm = T)
imputed$cent_schooling<- imputed$schooling  - mean(imputed$schooling , na.rm = T)

m1 <- coeftest(lm(moderation_score ~ assignment*cent_schooling + negro + indigena + blanco + age + conflict_score + gender+ factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
m2 <-coeftest(lm(moderation_alliance ~ assignment*cent_schooling + negro + indigena + blanco + age + conflict_score + gender+ factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
m3 <- coeftest(lm(moderation_platform ~ assignment*cent_schooling + negro + indigena + blanco + age + conflict_score + gender+ factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-A14.tex")
stargazer(m1,m2,m3, omit = "municipio", keep = c("assignment","cent_schooling"), 
          title = "Heterogeneous treatment effect by education on moderation")
sink()
round(p.adjust(c(m1[2,4], m2[2,4],m3[2,4]), "BH"),3)
round(p.adjust(c(m1[3,4], m2[3,4],m3[3,4]), "BH"),3)
round(p.adjust(c(m1[16,4], m2[16,4],m3[18,4]), "BH"),3)

#### Table A 15: Heterogeneous treatment effect by education on trust and participation ####
t1 <- coeftest(lm(trust_score ~ assignment*cent_schooling  + negro + indigena + blanco +age + conflict_score + gender + factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
t2 <- coeftest(lm(democracy_score ~ assignment*cent_schooling  + negro + indigena + blanco +age + conflict_score + gender+ factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
t3 <- coeftest(lm(participation_score ~ assignment*cent_schooling  + negro + indigena + blanco +age + conflict_score + gender+ factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-A15.tex")
stargazer(t1,t2,t3, omit = "municipio", keep = c("assignment","cent_schooling"), 
          title = "Heterogeneous treatment effect by education on trust and participation")
sink()

#### Table A 16: Heterogeneous effects on support for moderation by conflict experience ####
imputed$cent_conflict <- imputed$conflict_score - mean(imputed$conflict_score, na.rm = T)
imputed$cent_conflict <- imputed$conflict_score - mean(imputed$conflict_score, na.rm = T)

ncnm1 <- coeftest(lm(moderation_score  ~ assignment*cent_conflict + gender + age + schooling  + negro + indigena + blanco +factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
ncnm2 <- coeftest(lm(moderation_alliance  ~ assignment*cent_conflict +gender + age + schooling  + negro + indigena + blanco +factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
ncnm3 <- coeftest(lm(moderation_platform  ~ assignment*cent_conflict + gender + age + schooling  + negro + indigena + blanco +factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-A16.tex")
stargazer(ncnm1,ncnm2,ncnm3, omit = "municipio", keep = c("assignment","cent_conflict"), 
          title = "Heterogeneous effects on support for moderation by conflict experience")
sink()

round(p.adjust(c(ncnm1[2,4], ncnm2[2,4],ncnm3[2,4]), "BH"),3)
round(p.adjust(c(ncnm1[3,4], ncnm2[3,4],ncnm3[3,4]), "BH"),3)
round(p.adjust(c(ncnm1[16,4], ncnm2[16,4],ncnm3[18,4]), "BH"),3)

#### Table A 17: Heterogeneous effects on trust and participation by conflict experience ####
ncn1 <- coeftest(lm(trust_score ~ assignment*cent_conflict + gender + age + schooling  + negro + indigena + blanco +factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
ncn2 <- coeftest(lm(democracy_score ~ assignment*cent_conflict + gender + age + schooling  + negro + indigena + blanco +factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
ncn3 <-  coeftest(lm(participation_score ~ assignment*cent_conflict + gender + age + schooling  + negro + indigena + blanco + factor(municipio), data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-A17.tex")
stargazer(ncn1,ncn2,ncn3, omit = "municipio", keep = c("assignment","cent_conflict"), 
          title = "Heterogeneous effects on trust and participation by conflict experience")
sink()
#### Table A 18: OLS regression ideology and support for platform moderation in baseline ####
coridenone <- coeftest(lm(moderation_platform~ ideology_personal, data = imputedC),vcov = vcovHC, type = "HC0")
coride <- coeftest(lm(moderation_platform~ ideology_personal+ factor(municipio), data = imputedC),vcov = vcovHC, type = "HC0")
coridecon <- coeftest(lm(moderation_platform~ ideology_personal+ factor(municipio) + gender+ age + negro+ indigena+ blanco+ schooling+ conflict_score, data = imputedC),vcov = vcovHC, type = "HC0")
sink(file = "table-A18.tex")
stargazer(coridenone,coride,coridecon, omit = "municipio", keep = c("ideology_personal"), 
          title = "OLS regression ideology and support for platform moderation in baseline")
sink()
#### Table A 19: OLS regression conflict experience and education ####
corconedsec <- coeftest(lm(conflict_score~schooling + factor(municipio), data = imputedC),vcov = vcovHC, type = "HC0")
corconedconc <- coeftest(lm(conflict_score~schooling + factor(municipio) + gender+ age + negro+ indigena+ blanco, data = imputedC),vcov = vcovHC, type = "HC0")
corconedsef <- coeftest(lm(conflict_score~schooling  + factor(municipio), data = imputed))
corconedconf <- coeftest(lm(conflict_score ~schooling  + factor(municipio) + gender + age  + negro + indigena + blanco, data = imputed),vcov = vcovHC, type = "HC0")

sink(file = "table-A19.tex")
stargazer(corconedsec,corconedconc, corconedsef,corconedconf, omit = "municipio", keep = c("schooling"), 
          title = "OLS regression conflict experience and education")
sink()
#### Table A 20: OLS regression conflict experience and ideology ####
corconidsec <- coeftest(lm(conflict_score ~ideology_personal  + factor(municipio), data = imputedC),vcov = vcovHC, type = "HC0")
corconidconc <- coeftest(lm(conflict_score ~ideology_personal  + factor(municipio) + gender + age  + negro + indigena + blanco, data = imputedC),vcov = vcovHC, type = "HC0")
corconidsef <- coeftest(lm(conflict_score ~ideology_personal  + factor(municipio), data = imputed),vcov = vcovHC, type = "HC0")
corconidconf <- coeftest(lm(conflict_score ~ideology_personal  + factor(municipio) + gender + age  + negro + indigena + blanco, data = imputed),vcov = vcovHC, type = "HC0")

sink(file = "table-A20.tex")
stargazer(corconidsec,corconidconc, corconidsef,corconidconf, omit = "municipio", keep = c("ideology_personal"), 
          title = "OLS regression conflict experience and ideology")
sink()
#### Table A 22: Evaluating ideology and posturing mechanism #### 
p1 <- coeftest(lm(sat_implementationfarc ~  assignment+ gender + age  + negro + indigena + blanco + schooling  + conflict_score +factor(imputed$municipio) , data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
p2 <- coeftest(lm(ideology_personal~ assignment+ gender + age  + negro + indigena +blanco + schooling  + conflict_score +factor(imputed$municipio) , data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
p3 <- coeftest(lm(farc_loyalrevolutionary ~ assignment+ gender + age  + negro + indigena +blanco + schooling  + conflict_score +factor(imputed$municipio) , data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-A22.tex")
stargazer(p1,p3,p2, omit = "municipio", keep = c("assignment"), 
          title = "Evaluating ideology and posturing mechanism")
sink()
#### Table A 23: Testing for social desirability #### 
s1 <- coeftest(lm(voted2016 ~  assignment +factor(imputed$municipio) , data = imputed, weight = weight),vcov = vcovHC, type = "HC0")
s2 <- coeftest(lm(voted2016 ~  assignment+ gender + age  + negro + indigena +schooling  + conflict_score +factor(imputed$municipio) , data = imputed, weight = weight),vcov = vcovHC, type = "HC0")

sink(file = "table-A23.tex")
stargazer(s1,s2, omit = "municipio", keep = c("assignment"), 
          title = "Testing for social desirability")